home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / winlib3.zip / VIDSYS.H < prev    next >
Text File  |  1991-01-14  |  9KB  |  235 lines

  1.  /**********************************************
  2.   * Define video and other miscellaneous flags *
  3.   *********************************************/
  4.  
  5. #ifndef VSTRUCT_DEF
  6. #include <proto.h>
  7.  
  8.  #if defined (POWERC)
  9.    #define  crt_status_port  crtport
  10.    #define  pagesize_        pagesiz_
  11.    #define  caldelay_        caldely_
  12. #endif
  13.  
  14. #ifndef offsetof
  15. #define offsetof(type,memb) \
  16.            (unsigned)&((( type *)0x10)->memb)-(unsigned)(( type *)0x10)
  17. #endif
  18.  
  19.  /*************************
  20.  * Define Screen segments *
  21.  *************************/
  22.  
  23. #define MONO  0xB000
  24. #define COLOR 0xB800
  25. #define MAXBUFSIZE    1024
  26. #define MAXSCROLLWIDTH 140
  27.  
  28.  /********************************
  29.   * Define video block structure *
  30.   *******************************/
  31.  
  32. typedef struct
  33. {
  34.   int upx;            /* upper left column where
  35.                          video block is defined */
  36.   int upy;            /* upper row */
  37.   int lowx;           /* lower right column */
  38.   int lowy;           /* lower row */
  39.   int pagenum;        /* page number where block
  40.                          is opened */
  41.   char *scrnsave;     /* pointer to video block
  42.                          structure */
  43. } *VBLOCKPTR, VBLOCK;
  44.  
  45. typedef struct
  46. {
  47.   unsigned  scrnwrt_flag:1;        /* either BIOS or DMA          */
  48.   unsigned  cga_flag:1;            /* cga flag                    */
  49.   unsigned  mda_flag:1;            /* mono adapter flag           */
  50.   unsigned  vga_in_flag:1;         /* vga installed flag          */
  51.   unsigned  vga_c_flag:1;          /* vga color mode on           */
  52.   unsigned  vga_m_flag:1;          /* vga mono mode on            */
  53.   unsigned  mcga_c_flag:1;         /* MCGA color on               */
  54.   unsigned  mcga_m_flag:1;         /* MCGA mono on                */
  55.   unsigned  ega_in_flag:1;         /* ega installedf flag         */
  56.   unsigned  ega_a_flag:1;          /* ega active flag             */
  57.   unsigned  ega_c_flag:1;          /* ega is in color mode flag   */
  58.   unsigned  ega_m_flag:1;          /* ega is in mono mode flag    */
  59. }  SYS_FLAGS;
  60.  
  61.  
  62. typedef struct
  63. {
  64.   unsigned int video_mode;
  65.   unsigned int cursor_startline;
  66.   unsigned int cursor_endline;
  67.   unsigned int video_page;
  68.   unsigned int video_pagesize;
  69.   unsigned int video_rows;
  70.   unsigned int video_cols;
  71.   unsigned int char_height;
  72.   unsigned int crt_port_address;
  73.   unsigned int crt_mode_setting;
  74.   unsigned int crt_color_setting;
  75. } VIDEO_CONFIG;
  76.  
  77. #if defined (GLOBAL_DEF)
  78. #define EXTERN
  79. #else
  80. #define EXTERN extern
  81. #endif
  82.  
  83. EXTERN VIDEO_CONFIG   initial_video_startup;
  84. EXTERN int            is_vga_color;
  85. EXTERN int            default_screen_attr;         /* default screen attribute */
  86. EXTERN int            default_screen_tab_length;
  87. EXTERN unsigned       scrnseg_;
  88. EXTERN unsigned char  chksnow_;
  89. EXTERN SYS_FLAGS      video_system_flags;
  90. EXTERN unsigned       crt_status_port;
  91. EXTERN int            num_screen_rows;             /* current # of rows displayed */
  92. EXTERN int            num_screen_cols;             /* current # of columns displayed */
  93. EXTERN int            max_video_pages;
  94. EXTERN int            active_video_page;         /* current active display page */
  95. EXTERN int            visible_video_page;        /* current visible display page */
  96. EXTERN unsigned int   pagesize_;   /* size of video page in bytes */
  97. EXTERN int            current_video_mode;             /* current video mode */
  98. EXTERN unsigned char  window_char_buffer[MAXBUFSIZE]; /* global write buffer */
  99. EXTERN unsigned char  virtual_char_buffer[MAXBUFSIZE];
  100. EXTERN unsigned char  scroll_char_buffer[MAXSCROLLWIDTH];
  101. EXTERN unsigned       caldelay_;
  102.  
  103.  
  104.  /*******************
  105.  * Define box types *
  106.  ********************/
  107.  
  108.  
  109. #define DOUBLEBOX      "╔═╗║║╚═╝"
  110. #define SINGLEBOX      "┌─┐││└─┘"
  111. #define MIXEDBOX1      "╒═╕││╘═╛"
  112. #define MIXEDBOX2      "╓─╖║║╙─╜"
  113. #define HATCHBOX1      "░░░░░░░░"
  114. #define HATCHBOX2      "▒▒▒▒▒▒▒▒"
  115. #define HATCHBOX3      "▓▓▓▓▓▓▓▓"
  116. #define SOLIDBOX1      "█▀████▄█"
  117. #define SOLIDBOX2      "████████"
  118. #define BLANKBOX       "        "
  119. #define DOTTEDLINE     "---||---"
  120.  
  121.  
  122. #ifndef NUMBOXCHARS
  123. #define NUMBOXCHARS  8
  124. #endif
  125.  
  126. /* Macro Definitions */
  127.  
  128. #define SCREEN_WRITE_METHOD       video_system_flags.scrnwrt_flag
  129. #define CGA_MODE_ON               video_system_flags.cga_flag
  130. #define MONO_MODE_ON              video_system_flags.mda_flag
  131. #define VGA_INSTALLED             video_system_flags.vga_in_flag
  132. #define VGA_COLOR_ON              video_system_flags.vga_c_flag
  133. #define VGA_MONO_ON               video_system_flags.vga_m_flag
  134. #define MCGA_COLOR_ON             video_system_flags.mcga_c_flag
  135. #define MCGA_MONO_ON              video_system_flags.mcga_m_flag
  136. #define EGA_INSTALLED             video_system_flags.ega_in_flag
  137. #define EGA_MODE_ON               video_system_flags.ega_a_flag
  138. #define EGA_COLOR_ON              video_system_flags.ega_c_flag
  139. #define EGA_MONO_ON               video_system_flags.ega_m_flag
  140. #define VGA_MODE_ON               (VGA_COLOR_ON  || VGA_MONO_ON)
  141. #define MCGA_MODE_ON              (MCGA_COLOR_ON || MCGA_MONO_ON)
  142.  
  143. #define CHECK_SNOW                chksnow_
  144. #define SCREEN_SEGMENT            scrnseg_
  145. #define VIDEO_PAGESIZE            pagesize_
  146.  
  147. /*  Video Macros */
  148.  
  149. #define LINEMODE43       (get_video_info(4) == 43)
  150. #define LINEMODE50       (get_video_info(4) == 50)
  151. #define LINEMODE25       (get_video_info(4) == 25)
  152.  
  153. #define CREATE_VIDEO_ATTRIBUTE(x,y) (((int)(x)<<4) + (y)) /* creates a video attribute */
  154.  
  155. #define GET_BGROUND_COLOR(c)        ((int)(c)>>4)
  156. #define GET_FGROUND_COLOR(c)        ((int)(c) & 0x000F)
  157.  
  158. #define SCREEN_OFFSET(r,c,a)  \
  159.                           (((((r)-1)*num_screen_cols + (c)-1) + (a)*pagesize_)<<1)
  160. #define GET_SEGMENT(x)  \
  161.                   ((unsigned) ((long)(char far *)(x) >> 16))
  162. #define GET_OFFSET(x)   \
  163.                    ((unsigned) ((long)(char far *)(x) & 0x0000FFFF))
  164. #define SCREEN_OFFSET_ATTR(r,c,a)        (SCREEN_OFFSET((r),(c),(a))+1)
  165.  
  166. #define MAKE_FAR_POINTER(a,b)  ((char far *)(((unsigned long)(a) << 16)+(b)))
  167.  
  168.  
  169. #define GetVideoAttribute(row,col,page)   get_chat((row),(col),(page),1)
  170. #define GetVideoMode()                    get_video_info(1)
  171. #define MoveCursor(row,col,page)          goto_xy((row),(col),(page))
  172. #define ReportCharacter(row,col,page)     get_chat((row),(col),(page),0)
  173.  
  174.  
  175.  
  176. #if __cplusplus
  177.   extern "C" {
  178. #endif
  179.  
  180.  
  181.  
  182. /* Fast Output/Non-window related Video Functions */
  183. int           CheckVideoPage P((int page));
  184. void          ClearRegion P((int urow, int ucol, int lrow, int lcol, int attr));
  185. void          ClearScreen P((int attr));
  186. void          GetCursorPosition P((int *row,int *col, int page));
  187. void          GetVideoBiosInfo P((VIDEO_CONFIG *video_struct));
  188. void          ScrollScreenUp P((int numlines, int urow, int ucol, int lrow,
  189.                                 int lcol, int attr));
  190. void          ScrollScreenDown P((int numlines, int urow, int ucol, int lrow,
  191.                                 int lcol, int attr));
  192. int           SetActiveVideoPage P((int page));
  193. int           SetVisibleVideoPage P((int page));
  194. void          SetVideoMode P((int modenum));
  195. int           SetVideoRows P((int numrows, int flag));
  196. void          VideoDrawBox P((int urow, int ucol, int lrow, int lcol, char *box));
  197. void          VideoDrawBoxAttr P((int urow, int ucol, int lrow, int lcol,
  198.                                   char *box, int attr));
  199. void          VideoFree P((VBLOCKPTR vid_block));
  200. void          VideoMove P((VBLOCKPTR vid_block));
  201. void          VideoPrintf P((char *format, ...));
  202. void          VideoPrintfAttr P((int attr, char *format, ...));
  203. VBLOCKPTR     VideoSave P((int urow, int ucol, int lrow, int lcol));
  204. void          VideoRestore P((VBLOCKPTR vid_block));
  205. void          VideoWriteString P((char *string, int row, int col));
  206. void          VideoWriteStringAttr P((char *string, int row, int col, int attr));
  207. void          VideoWriteAttributes P((char *string, int row, int col,
  208.                                       int length));
  209. void          VideoWriteCenterString P((char *string, int row));
  210. void          VideoWriteCenterStringAttr P((char *string, int row, int attr));
  211. void          VideoWriteCharAndAttr P((char *string, int row, int col,
  212.                                        int length));
  213. void          VideoWriteStringCC P((char *string, int row, int col));
  214. void          VideoWriteStringCCAttr P((char *string, int row, int col,
  215.                                         int attr));
  216. void          VideoWriteStringRJ P((char *string, int row, int col));
  217. void          VideoWriteStringRJAttr P((char *string, int row, int col,
  218.                                         int attr));
  219. void          VideoReadAttributes P((char *buffer, int row, int col,
  220.                                      int length));
  221. void          VideoReadCharacters P((char *buffer, int row, int col,
  222.                                      int length));
  223. void          VideoReadCharAndAttr P((char *buffer, int row, int col,
  224.                                       int length));
  225.  
  226. int           InitializeScanLines(int,int);
  227. int           LoadCharacterSet(int,int);
  228. void          goto_xy P((int,int,int));
  229. #if __cplusplus
  230.   }
  231. #endif
  232. #define VSTRUCT_DEF
  233.  
  234. #endif
  235.